package com.tnsw.facebookautoliker;

import java.util.Arrays;

import com.facebook.Session;
import com.facebook.SessionState;

import android.os.Bundle;
import android.app.Activity;
import android.util.Log;
import android.view.Menu;

public class SecondActivity extends Activity {

	private String tag = "SecondActivity";
	
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_second);
		
		Session session = Session.openActiveSessionFromCache(this);
		if (session != null) {
			Log.d(tag, "accessToken=" + session.getAccessToken());
			Session.OpenRequest openRequest = null;
			openRequest = new Session.OpenRequest(this);
			openRequest.setPermissions(Arrays.asList("read_stream", "publish_stream"));
			
			session.addCallback(new Session.StatusCallback() {
				
				@Override
				public void call(Session session, SessionState state, Exception exception) {
					// TODO Auto-generated method stub
					
				}
			});
			
			Log.d(tag, "calling openForPublish...");
			session.openForPublish(openRequest);
			Log.d(tag, "done.");
		}
	}

	@Override
	public boolean onCreateOptionsMenu(Menu menu) {
		// Inflate the menu; this adds items to the action bar if it is present.
		getMenuInflater().inflate(R.menu.second, menu);
		return true;
	}

}
